import types from './../types/indexTypes' ;
// 数据请求
export default {
    getList:function (id) {
        return (async) => {
            ajax.get({
                    url : '/v2/movie/in_theaters',
                    data:''
                })
                .then(function (resp) {
                    ajax.get({
                        url : '/v2/movie/coming_soon',
                        data:''
                    })
                    .then(function (resp1) {
                        async({
                            type:types.GET_LIST,
                            nowData:resp1.subjects,
                            commingData:resp.subjects
                        })
                    })
                })
        }
    },
    getDetail:function (id,callBack) {
        if(callBack == undefined || typeof callBack === Function) {
            callBack = ()=>{}
        }
        return (async) => {
            ajax.get({
                url:'/v2/movie/search?tag='+id ,
                data:""
            })
                .then((res) => {
                    async({
                        type:types.GET_DETAIL,
                        detailData:res
                    })
                    callBack()
                })
        }

    },
    resourceDetail(id){
        return (async) => {
            ajax.get({
                url:'/v2/movie/subject/'+id ,
                data:""
            })
                .then((res) => {
                    async({
                        type:types.RESOURCE_DETAIL,
                        resourceData:res
                    })
                })
        }
    }
};